package ch.sv7.tool.dbmanager.types;

import java.sql.DatabaseMetaData;

/**
 * The JDBC type information
 *
 * @author svt
 *
 */
public class TypeInfo implements Cloneable {
	
	private String typeName;
	private int jdbcType;
	private int precision;
	private String literalPrefix;
	private String literalSuffix;
	private String createParams;
	private short nullable;
	private boolean caseSensitive;
	private short searchable;
	private boolean unsigned;
	private boolean moneyValue;
	private boolean autoIncrement;
	private String localTypeName;
	private short minScale;
	private short maxScale;
	private int numPrecisionRadix;
	
	/**
	 * 
	 */
	public TypeInfo() {
		super();
	}
	
	/**
	 * @param typeName
	 * @param jdbcType
	 * @param precision
	 * @param literalPrefix
	 * @param literalSuffix
	 * @param createParams
	 * @param nullable
	 * @param caseSensitive
	 * @param searchable
	 * @param unsigned
	 * @param moneyValue
	 * @param autoIncrement
	 * @param localTypeName
	 * @param minScale
	 * @param maxScale
	 * @param numPrecisionRadix
	 */
	public TypeInfo(String typeName, int jdbcType, int precision, String literalPrefix, String literalSuffix,
			String createParams, short nullable, boolean caseSensitive, short searchable, boolean unsigned,
			boolean moneyValue, boolean autoIncrement, String localTypeName, short minScale, short maxScale,
			int numPrecisionRadix) {
		super();
		this.typeName = typeName;
		this.jdbcType = jdbcType;
		this.precision = precision;
		this.literalPrefix = literalPrefix;
		this.literalSuffix = literalSuffix;
		this.createParams = createParams;
		this.nullable = nullable;
		this.caseSensitive = caseSensitive;
		this.searchable = searchable;
		this.unsigned = unsigned;
		this.moneyValue = moneyValue;
		this.autoIncrement = autoIncrement;
		this.localTypeName = localTypeName;
		this.minScale = minScale;
		this.maxScale = maxScale;
		this.numPrecisionRadix = numPrecisionRadix;
	}
	
	public Object clone() {
		try {
			return super.clone();
		} catch (CloneNotSupportedException e) {
			throw new RuntimeException(e);
		}
	}

	/**
	 * @return the typeName
	 */
	public String getTypeName() {
		return typeName;
	}
	/**
	 * @param typeName the typeName to set
	 */
	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}
	/**
	 * @return the jdbcType
	 */
	public int getJdbcType() {
		return jdbcType;
	}
	/**
	 * @param jdbcType the jdbcType to set
	 */
	public void setJdbcType(int jdbcType) {
		this.jdbcType = jdbcType;
	}
	/**
	 * @return the precision
	 */
	public int getPrecision() {
		return precision;
	}
	/**
	 * @param precision the precision to set
	 */
	public void setPrecision(int precision) {
		this.precision = precision;
	}
	/**
	 * @return the literalPrefix
	 */
	public String getLiteralPrefix() {
		return literalPrefix;
	}
	/**
	 * @param literalPrefix the literalPrefix to set
	 */
	public void setLiteralPrefix(String literalPrefix) {
		this.literalPrefix = literalPrefix;
	}
	/**
	 * @return the literalSuffix
	 */
	public String getLiteralSuffix() {
		return literalSuffix;
	}
	/**
	 * @param literalSuffix the literalSuffix to set
	 */
	public void setLiteralSuffix(String literalSuffix) {
		this.literalSuffix = literalSuffix;
	}
	/**
	 * @return the createParams
	 */
	public String getCreateParams() {
		return createParams;
	}
	/**
	 * @param createParams the createParams to set
	 */
	public void setCreateParams(String createParams) {
		this.createParams = createParams;
	}
	/**
	 * @return the nullable
	 */
	public short getNullable() {
		return nullable;
	}
	/**
	 * @param nullable the nullable to set
	 */
	public void setNullable(short nullable) {
		this.nullable = nullable;
	}
	
	public boolean isNullable() {
		return nullable == DatabaseMetaData.attributeNullable;
	}
	/**
	 * @return the caseSensitive
	 */
	public boolean isCaseSensitive() {
		return caseSensitive;
	}
	/**
	 * @param caseSensitive the caseSensitive to set
	 */
	public void setCaseSensitive(boolean caseSensitive) {
		this.caseSensitive = caseSensitive;
	}
	/**
	 * @return the searchable
	 */
	public short getSearchable() {
		return searchable;
	}
	/**
	 * @param searchable the searchable to set
	 */
	public void setSearchable(short searchable) {
		this.searchable = searchable;
	}
	/**
	 * @return the unsigned
	 */
	public boolean isUnsigned() {
		return unsigned;
	}
	/**
	 * @param unsigned the unsigned to set
	 */
	public void setUnsigned(boolean unsigned) {
		this.unsigned = unsigned;
	}
	/**
	 * @return the moneyValue
	 */
	public boolean isMoneyValue() {
		return moneyValue;
	}
	/**
	 * @param moneyValue the moneyValue to set
	 */
	public void setMoneyValue(boolean moneyValue) {
		this.moneyValue = moneyValue;
	}
	/**
	 * @return the autoIncrement
	 */
	public boolean isAutoIncrement() {
		return autoIncrement;
	}
	/**
	 * @param autoIncrement the autoIncrement to set
	 */
	public void setAutoIncrement(boolean autoIncrement) {
		this.autoIncrement = autoIncrement;
	}
	/**
	 * @return the localTypeName
	 */
	public String getLocalTypeName() {
		return localTypeName;
	}
	/**
	 * @param localTypeName the localTypeName to set
	 */
	public void setLocalTypeName(String localTypeName) {
		this.localTypeName = localTypeName;
	}
	/**
	 * @return the minScale
	 */
	public short getMinScale() {
		return minScale;
	}
	/**
	 * @param minScale the minScale to set
	 */
	public void setMinScale(short minScale) {
		this.minScale = minScale;
	}
	/**
	 * @return the maxScale
	 */
	public short getMaxScale() {
		return maxScale;
	}
	/**
	 * @param maxScale the maxScale to set
	 */
	public void setMaxScale(short maxScale) {
		this.maxScale = maxScale;
	}
	/**
	 * @return the numPrecisionRadix
	 */
	public int getNumPrecisionRadix() {
		return numPrecisionRadix;
	}
	/**
	 * @param numPrecisionRadix the numPrecisionRadix to set
	 */
	public void setNumPrecisionRadix(int numPrecisionRadix) {
		this.numPrecisionRadix = numPrecisionRadix;
	}
	
}
